import request from "@/request/api";
/* ----------------大修工单---------------- */

//查询分页列表
export function getListApi(data) {
  return request({
    url: "/eam-service-order/overhaul/queryList",
    method: "get",
    params: data,
  });
}
//查询可提交人员列表
export function getSubmitUserApi(orderId) {
  return request({
    url: "/eam-service-order/overhaul/allowSubmit",
    method: "get",
    params: {
      orderId
    },
  });
}
//查询单个工单
export function getDetailsApi(id = "") {
  return request({
    url: "/eam-service-order/overhaul/queryById",
    method: "get",
    params: {
      id
    },
  });
}

/* 大修工单提交（无内容提交，只修改工单状态） */
export function submitOrder(data) {
  return request({
    url: "/eam-service-order/overhaul/submit",
    method: "post",
    data: data,
  });
}
//删除单个工单
export function deleteApi(id = '') {
  return request({
    url: "/eam-service-order/overhaul/deleteById",
    method: "delete",
    params: {
      id
    },
  });
}
/* 作废 */
export function invalidApi(orderId = '') {
  return request({
    url: "/eam-service-order/overhaul/deprecated",
    method: "delete",
    params: {
      orderId
    },
  });
}
//新增或修改
export function saveOrUpdate(data) {
  return request({
    url: "/eam-service-order/overhaul/draft/saveOrUpdate",
    method: "post",
    data: data,
  });
}
//获取大修的作业表单
export function getWorkListFormApi(data) {
  return request({
    url: "/eam-service-standard/overhaul/list",
    method: "get",
    params: data,
  });
}

/* 派工状态 */
//获取派工信息
export function getMaintainDispatchApi(orderId = "") {
  return request({
    url: "/eam-service-order/overhaul/dispatch/queryDispatchInfoByOrderId",
    method: "get",
    params: {
      orderId
    },
  });
}
//获取派工信息
export function saveMaintainDispatchApi(data) {
  return request({
    url: "/eam-service-order/overhaul/dispatch/saveDispatchInfo",
    method: "post",
    data: data,
  });
}
/* 待执行 */
export function performOrder(data) {
  return request({
    url: "/eam-service-order/overhaul/toExecute/saveOrUpdate",
    method: "post",
    data: data,
  });
}
/* 执行中 */
/* 关联试验工单 */

/* 新增大修工单与试验工单的关联表 */
export function addExperimentApi(data) {
  return request({
    url: "/eam-service-order/overhaulExperimentRel/insertBatch",
    method: "post",
    data: data,
  });
}
/* 根据id查询大修工单与试验工单的关联表 */
export function getExperimentApi(data) {
  return request({
    url: "/eam-service-order/overhaul/form/queryExperimentVoList",
    method: "get",
    params: data,
  });
}
/* 删除大修工单与试验工单的关联表 */
export function deleteExperimentApi(data) {
  return request({
    url: "/eam-service-order/overhaulExperimentRel/deleteByOverhaulId",
    method: "delete",
    params: data,
  });
}


//根据工单id查询执行信息
export function getExecutionApi(orderId = "") {
  return request({
    url: "/eam-service-order/overhaul/execute/queryExecuteInfoByOrderId",
    method: "get",
    params: {
      orderId
    },
  });
}
//根据工单id只查询执行信息
export function getExecuteInfoByOrderId(orderId = "") {
  return request({
    url: "/eam-service-order/overhaul/execute/getExecuteInfoByOrderId",
    method: "get",
    params: {
      orderId
    },
  });
}
/* 签名 */
export function updateSignInfo(data) {
  return request({
    url: "/eam-service-order/overhaul/execute/sign/saveOrUpdate",
    method: "post",
    data: data,
  });
}
/* 根据作业表单ID查详情 */
export function getWorkListApi(formId) {
  return request({
    url: "/eam-service-order/overhaul/form/getById",
    method: "get",
    params: {
      formId
    },
  });
}
//作业过程项-列值修改（含确认状态和备注）
export function saveTableData(data) {
  return request({
    url: "/eam-service-order/overhaul/execute/" +
      data.itemId + '/' +
      data.key + '/' +
      data.value,
    method: "get",
  });
}
//作业过程-数据记录变量
export function saveVariable(data) {
  return request({
    url: "/eam-service-order/overhaul/execute/params/saveOrUpdate",
    method: "post",
    data: data,
  });
}
//新增或修改(表单,作业过程)，返回表单id
export function saveWorkForm(data) {
  return request({
    url: "/eam-service-order/overhaul/execute/saveOrUpdate",
    method: "post",
    data: data,
  });
}
//保存执行信息，返回执行信息id
export function saveExecuteInfo(data) {
  return request({
    url: "/eam-service-order/overhaul/execute/saveExecuteInfo",
    method: "post",
    data: data,
  });
}
//删除单个工单
export function deleteperformApi(executeId = '') {
  return request({
    url: "/eam-service-order/overhaul/execute/deleteExecuteInfoByExecuteId",
    method: "delete",
    params: {
      executeId
    },
  });
}
/* 编制大修报告 */
/* 获取大修报告 */
export function getReportApi(orderId = "") {
  return request({
    url: "/eam-service-order/overhaul/prepareReport/getPrepareReportByOrderId",
    method: "get",
    params: {
      orderId
    },
  });
}
/* 保存大修报告 */
export function saveReportApi(data) {
  return request({
    url: "/eam-service-order/overhaul/prepareReport/saveOrUpdate",
    method: "post",
    data: data,
  });
}